package com.irdstudio.efp.flow.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.efp.flow.service.dao.InstFlowParamDao;
import com.irdstudio.efp.flow.service.domain.InstFlowParam;
import com.irdstudio.efp.flow.service.facade.InstFlowParamService;
import com.irdstudio.efp.flow.service.vo.InstFlowParamVO;
import com.irdstudio.basic.framework.core.base.FrameworkService;

/**
 * 
 * 
 * 
 * @author Cytus_
 * @since 2018年5月8日 下午8:02:52
 * @version 1.0
 *
 */
@Service("instFlowParamService")
public class InstFlowParamServiceImpl implements InstFlowParamService, FrameworkService {

	
	private static Logger logger = LoggerFactory.getLogger(InstFlowParamServiceImpl.class);
	
	
	@Autowired
	private InstFlowParamDao instFlowParamDao;
	
	
	public InstFlowParamVO queryContent(InstFlowParamVO vo) {
		logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"查询信息开始......");
		InstFlowParamVO paramVo = null;
		try {
			InstFlowParam queryParam = beanCopy(vo, new InstFlowParam());
			InstFlowParam param = this.instFlowParamDao.queryContent(queryParam);
			paramVo = beanCopy(param, new InstFlowParamVO());
			logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"查询信息结束......");
		} catch (Exception e) {
			logger.error("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"查询信息出现异常!", e);
		}
		return paramVo;
	}

	public int insertInstFlowParam(InstFlowParamVO vo) {
	    logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"新增数据开始......");
		int num = 0;
		InstFlowParam param = beanCopy(vo, new InstFlowParam());
		try {
			num = this.instFlowParamDao.insertInstFlowParam(param);
			logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"新增数据结束......");
		} catch (Exception e) {
		    logger.error("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"新增数据出现异常!", e);
			num = -1;
		}
		return num;
	}

	public int deleteByPk(InstFlowParamVO vo) {
	    logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"删除数据开始......");
		int num = 0;
		InstFlowParam param = new InstFlowParam();
		beanCopy(vo, param);
		try {
			num = this.instFlowParamDao.deleteByPk(param);
			logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"删除数据结束......");
		} catch (Exception e) {
		    logger.debug("根据业务流水号:"+ vo.getBizSerno() +"节点实例号:"+ vo.getInstNodeId() +"任务编号："+ vo.getTaskId() +"删除数据结束......");
			num = -1;
		}
		return num;
	}
	
}
